*****Conscription and Military Service: Do They Result in Future Violent and Non-Violent Incarcerations and Recidivism?  Wang, Flores-Lagunes 2020*****

cd "C:\Users\xinto\Dropbox\Vietnam Veteran Paper\Crime Paper\2020 JHR Data\1. Main Dataset"

set more off
clear all
set memory 350m
set matsize 800

*****1986: State Survey******
clear
use SISFC1991

***Study***
gen study=1991

***ID***
gen id=V5

***Male***
tab V9, nol
gen male=9
replace male=1 if V9==1 
replace male=0 if V9==2 
tab male

***Final Weight***
gen weight=V1331
egen total_male_inmate=total(weight) if male==1 
tab total_male_inmate

***Birth Month***
tab V10, nol
gen birthMonth=99
replace birthMonth=V10 if V10!=98
tab birthMonth

***Birth Day***
tab V11, nol
gen birthDay=99 
replace birthDay=V11 if V11!=98
tab birthDay

***Birth Year***
tab V12, nol
gen birthYear=99 
replace birthYear=V12 if V12!=98
tab birthYear

***Age (no missing values)***
tab V15, nol
gen age=99
replace age=V15 if V15!=98 
tab age

***White***
tab V17, nol
gen white=9 
replace white=1 if V17==1
replace white=0 if (V17==2 | V17==3 | V17==4 | V17==5)
tab white

***Hispanic***
tab V18 
gen spainHisp=9
replace spainHisp=1 if V18==1
replace spainHisp=0 if V18==2
tab spainHisp

****Married****
tab V22, nol
gen married=9
replace married=1 if V22==1
replace married=0 if (V22==2| V22==3 | V22==4 | V22==5 ) 
tab married

***Divorced (no missing values)***
tab V22, nol
gen divorced=9
replace divorced=1 if V22==3
replace divorced=0 if (V22==1| V22==2 | V22==4 | V22==5 )
tab divorced

***Never Married***
tab V22, nol
gen neverMarried=9
replace neverMarried=1 if V22==5
replace neverMarried=0 if (V22==1| V22==2 | V22==3 | V22==4)
tab neverMarried

***Ever served in the military***
tab V23, nol
gen armForce=9 
replace armForce=1 if V23==1
replace armForce=0 if V23==2
tab armForce

***Vietnam Era 
tab V24, nol 
gen vietEra=9 
replace vietEra=1 if V24==1 
replace vietEra=0 if V24==2 | V23==2
tab vietEra

***Stationed in Vietnam***
tab V25
gen stationedVietnam=9
replace stationedVietnam=1 if V25==1
replace stationedVietnam=0 if V25==2 | vietEra==0
tab stationedVietnam

***Saw Combat***
tab V26
gen sawCombat=9
replace sawCombat=1 if V26==1
replace sawCombat=0 if V26==2 | stationedVietnam==0
tab sawCombat

***Serve Branches*** 
tab V29, nol
gen serveBranch=V29 

***Serve in Army***
gen army=9
replace army=1 if V29==1
replace army=0 if (V29!=1 & V29!=8) | V23==2 
tab army

***Month Enter Military***
tab V30, nol
gen monthEnterMilitary=99
replace  monthEnterMilitary=V30 if V30!=98 
tab monthEnterMilitary

***Year Enter Military***
tab V31, nol
gen yearEnterMilitary=99 
replace yearEnterMilitary=V31 if V31!=98  
tab yearEnterMilitary

***Month Discharged Military***
tab V32, nol
gen monthDischargedMilitary=99
replace monthDischargedMilitary=V32 if  V32!=98
tab monthDischargedMilitary

***Year Discharged Military***
tab V33, nol
gen yearDischargedMilitary=99
replace yearDischargedMilitary=V33 if V33!=98 
tab yearDischargedMilitary

/***Member of National Goard***
tab V435
gen memberReserve=9 
replace memberReserve=1 if V435==1
replace memberReserve=0 if V435==2
 

***Eligible for VA Benefits or Education***
tab V438
gen eligibleVA=9
replace eligibleVA=1 if V438==1 
replace eligibleVA=0 if V438==2 
*/ 

***Month of Admission***
tab V1274, nol
gen admissionMonth=99
replace admissionMonth=V1274 if V1274!=98
tab admissionMonth

***Year of Admission***
tab V1276, nol
gen admissionYear=99
replace admissionYear=V1276 if V1276!=98
tab admissionYear

***Current Offense 1 ***
tab V1268, nol
gen currentOffense1=999
replace currentOffense1=V1268 if V1268!=998
tab currentOffense1

***Current Offense 2 ***
tab V1269, nol
gen currentOffense2=999
replace currentOffense2=V1269 if V1269!=998
tab currentOffense2

***Current Offense 3***
tab V1270, nol
gen currentOffense3=999
replace currentOffense3=V1270 if V1270!=998
tab currentOffense3

***Current Offense 4***
tab V1271, nol
gen currentOffense4=999
replace currentOffense4=V1271 if V1271!=998
tab currentOffense4

***Current Offense 5***
tab V1272, nol
gen currentOffense5=999
replace currentOffense5=V1272 if V1272!=998
tab currentOffense5




***Current Offense 1 ***
tab V1268, nol
gen LScurrentOffense1=999
replace LScurrentOffense1=V1268 if V1268!=998
tab LScurrentOffense1

***Current Offense 2 ***
tab V1269, nol
gen LScurrentOffense2=999
replace LScurrentOffense2=V1269 if V1269!=998
tab LScurrentOffense2

***Current Offense 3***
tab V1270, nol
gen LScurrentOffense3=999
replace LScurrentOffense3=V1270 if V1270!=998
tab LScurrentOffense3

***Current Offense 4***
tab V1271, nol
gen LScurrentOffense4=999
replace LScurrentOffense4=V1271 if V1271!=998
tab LScurrentOffense4

***Current Offense 5***
tab V1272, nol
gen LScurrentOffense5=999
replace LScurrentOffense5=V1272 if V1272!=998
tab LScurrentOffense5 

***Current Offense 6***
tab V1273, nol
gen LScurrentOffense6=999
replace LScurrentOffense6=V1273 if V1273!=998
tab LScurrentOffense6


***Month of Arrest 
tab V1278, nol 
gen arrestMonth=99
replace arrestMonth=V1278 if V1278!=98
tab arrestMonth

***Year of Arrest 
tab V1279, nol 
gen arrestYear=99 
replace arrestYear=V1279 if V1279!=98
tab arrestYear

***************Prior Incarceration***************
***Previous Incarceration***
tab V1282, nol
gen priorIncarceration=9
replace priorIncarceration=1 if V1282==1 
replace priorIncarceration=0 if V1282==2 
tab priorIncarceration

***Total times of arrested*** 
tab V496, nol 
gen totalArrest=999
replace totalArrest=V496 if V496!=998
tab totalArrest

***Age at First Arrest***
tab V497, nol
gen ageFirstArrest=99 
replace ageFirstArrest=V497 if V497!=98 
tab ageFirstArrest

***Reason for the arrest offense 1***
tab V499, nol 
gen firstArrestOffense1=999
replace firstArrestOffense1=V499 if V499!=998
tab firstArrestOffense1

***Reason for the arrest offense 2***
tab V500, nol 
gen firstArrestOffense2=999
replace firstArrestOffense2=V500 if V500!=998
tab firstArrestOffense2

***Reason for the arrest offense 3***
tab V501, nol 
gen firstArrestOffense3=999
replace firstArrestOffense3=V501 if V501!=998
tab firstArrestOffense3

***Reason for the arrest offense 4***
tab V502, nol 
gen firstArrestOffense4=999
replace firstArrestOffense4=V502 if V502!=998
tab firstArrestOffense4

***Reason for the arrest offense 5***
tab V503, nol 
gen firstArrestOffense5=999
replace firstArrestOffense5=V503 if V503!=998
tab firstArrestOffense5

/***Age First Incarcerated***
tab V363
gen ageFirstIncarcerated=999 
replace ageFirstIncarcerated=V363 if (V363!=98 & V363!=99)
tab ageFirstIncarcerated
*/ 

***Ever on Probation***
tab V504, nol
gen everProbation=9
replace everProbation=1 if V504==1 
replace everProbation=0 if V504==2 
tab everProbation

***Total times on probation as a juvenile*** 
tab V505, nol 
gen timesOnProbationJuv=99 
replace timesOnProbationJuv=V505 if V505!=98
replace timesOnProbationJuv=0 if V506==0
replace timesOnProbationJuv=0 if everProbation==0
tab timesOnProbationJuv

***age first on Probation as Juvenile***
tab V507, nol
gen ageProbationJuv=V507
replace ageProbationJuv=99 if ageProbationJuv==98
tab ageProbationJuv

***Offense 1 on Probation as Juvenile***
tab V508, nol
gen firstProbOffenseJuv1=999
replace firstProbOffenseJuv1=V508 if V508!=998
tab firstProbOffenseJuv1

***Offense 2 on Probation as Juvenile***
tab V509, nol
gen firstProbOffenseJuv2=999
replace firstProbOffenseJuv2=V509 if V509!=998
tab firstProbOffenseJuv2

***Offense 3 on Probation as Juvenile***
tab V510, nol
gen firstProbOffenseJuv3=999
replace firstProbOffenseJuv3=V510 if V510!=998
tab firstProbOffenseJuv3

***Offense 4 on Probation as Juvenile***
tab V511, nol
gen firstProbOffenseJuv4=999
replace  firstProbOffenseJuv4=V511 if V511!=998
tab firstProbOffenseJuv4

***Offense 5 on Probation as Juvenile***
tab V512, nol
gen firstProbOffenseJuv5=999
replace firstProbOffenseJuv5=V512 if V512!=998
tab firstProbOffenseJuv5

***Times on Probation as Adult***
tab V513, nol
gen timesProbationAdu=99
replace timesProbationAdu=V513 if V513!=98
replace timesProbationAdu=0 if V514==0
replace timesProbationAdu=0 if everProbation==0
tab timesProbationAdu

***Age first on Probation as a adult***
tab V515, nol
gen ageProbationAdu=V515
replace ageProbationAdu=99 if ageProbationAdu==98
tab ageProbationAdu

***Offense 1 on Probation as Adult***
tab V516, nol
gen firstProbOffenseAdu1=V516
replace firstProbOffenseAdu1=999 if firstProbOffenseAdu1==998
tab firstProbOffenseAdu1

***Offense 2 on Probation as Adult***
tab V517, nol
gen firstProbOffenseAdu2=V517
replace firstProbOffenseAdu2=999 if firstProbOffenseAdu2==998
tab firstProbOffenseAdu2

***Offense 3 on Probation as Adult***
tab V518, nol
gen firstProbOffenseAdu3=V518
replace firstProbOffenseAdu3=999 if firstProbOffenseAdu3==998
tab firstProbOffenseAdu3

***Offense 4 on Probation as Adult***
tab V519
gen firstProbOffenseAdu4=V519
replace firstProbOffenseAdu4=999 if firstProbOffenseAdu4==998
tab firstProbOffenseAdu4

***Offense 5 on Probation as Adult***
tab V520
gen firstProbOffenseAdu5=V520
replace firstProbOffenseAdu5=999 if firstProbOffenseAdu5==998
tab firstProbOffenseAdu5

***Convicted for Drunkeness (petty off)***
tab V521, nol
gen convDrunk=9
replace convDrunk=1 if V521!=0 & V521!=8
replace convDrunk=0 if V521==0 
tab convDrunk

***Served for petty off 
tab V522, nol
gen servDrunk=9
replace servDrunk=1 if V522==1 
replace servDrunk=0 if (V522==2 | (V522==8 & V521==0))
tab servDrunk

***Times as a Juvenile: Serve for Drunkeness***
tab V523, nol
gen timesDrunkAsJuv=99
replace timesDrunkAsJuv=V523 if V523!=98 
replace timesDrunkAsJuv=0 if (V524==0 | servDrunk==0)
tab timesDrunkAsJuv

***Times for Drunkeness as Adult***
tab V525, nol
gen timesDrunkAsAdu=9999
replace timesDrunkAsAdu=V525 if V525!=9998 
replace timesDrunkAsAdu=0 if (V526==0 | servDrunk==0)
tab timesDrunkAsAdu

***Serve Other Than Drunkeness***
tab V527, nol
gen servOther=9 
replace servOther=1 if V527==1 
replace servOther=0 if V527==2 | V1282==2 
tab servOther

***Serve times for Others as Juvenile***
tab V528, nol
gen timesOtherJuv=99
replace timesOtherJuv=V528 if V528!=98 
replace timesOtherJuv=0 if (servOther==0 | V529==0)
tab timesOtherJuv

***Serve times for Others as Adult***
tab V530, nol
gen timesOtherAdu=999
replace timesOtherAdu=V530 if V530!=998 
replace timesOtherAdu=0 if (servOther==0| V531==0)
tab timesOtherAdu

/***Times Confined (previously)***
drop timesConfined
tab V386
gen timesConfined=V386
replace timesConfined=999 if timesConfined==998
replace timesConfined=0 if V1118==2
tab timesConfined
*/ 

***First serve offense 1 (actuallt it is last served)***
tab V532, nol
gen firstServeOffense1=V532
replace firstServeOffense1=999 if firstServeOffense1==998
tab firstServeOffense1
***First serve offense 2***
tab V533, nol
gen firstServeOffense2=V533
replace firstServeOffense2=999 if firstServeOffense2==998
tab firstServeOffense2
***First serve offense 3***
tab V534, nol
gen firstServeOffense3=V534
replace firstServeOffense3=999 if firstServeOffense3==998
tab firstServeOffense3
***First serve offense 4***
tab V535, nol
gen firstServeOffense4=V535
replace firstServeOffense4=999 if firstServeOffense4==998
tab firstServeOffense4
***First serve offense 5***
tab V536, nol
gen firstServeOffense5=V536
replace firstServeOffense5=999 if firstServeOffense5==998
tab firstServeOffense5
***First serve admission Month***
tab V562, nol
gen firstAdmitMonth=99
replace firstAdmitMonth=V562 if V562!=98
tab firstAdmitMonth
***First serve admission Year***
tab V563, nol
gen firstAdmitYear=99
replace firstAdmitYear=V563 if V563!=98
tab firstAdmitYear
***First serve Age***
tab V565
gen firstAdmitAge=V565
replace firstAdmitAge=99 if firstAdmitAge==98 
tab firstAdmitAge
***First serve as adult***
tab V560
gen firstServeAdult=9
replace firstServeAdult=1 if (V560==1 | V560==2 ) 
replace firstServeAdult=0 if V560==3 
tab firstServeAdult


***Second serve offense 1***
tab V576, nol
gen secondServeOffense1=V576
replace secondServeOffense1=999 if secondServeOffense1==998
tab secondServeOffense1
***Second serve offense 2***
tab V577, nol
gen secondServeOffense2=V577
replace secondServeOffense2=999 if secondServeOffense2==998
tab secondServeOffense2
***Second serve offense 3***
tab V578, nol
gen secondServeOffense3=V578
replace secondServeOffense3=999 if secondServeOffense3==998
tab secondServeOffense3
***Second serve offense 4***
tab V579, nol
gen secondServeOffense4=V579
replace secondServeOffense4=999 if secondServeOffense4==998
tab secondServeOffense4
***Second serve offense 5***
tab V580, nol
gen secondServeOffense5=V580
replace secondServeOffense5=999 if secondServeOffense5==998
tab secondServeOffense5
***Second serve admission Month***
tab V583, nol
gen secondAdmitMonth=99
replace secondAdmitMonth=V583 if V583!=98
tab secondAdmitMonth
***Second serve admission Year***
tab V584, nol
gen secondAdmitYear=99
replace secondAdmitYear=V584 if V584!=98 
tab secondAdmitYear
***Second serve Age***
tab V586
gen secondAdmitAge=V586
replace secondAdmitAge=99 if secondAdmitAge==98 
tab secondAdmitAge
***Second serve as adult***
tab V581, nol
gen secondServeAdult=9
replace secondServeAdult=1 if (V581==1 | V581==2) 
replace secondServeAdult=0 if V581==3 
tab secondServeAdult


***Third serve offense 1***
tab V592, nol
gen thirdServeOffense1=V592
replace thirdServeOffense1=999 if thirdServeOffense1==998
tab thirdServeOffense1
***Third serve offense 2***
tab V593, nol
gen thirdServeOffense2=V593
replace thirdServeOffense2=999 if thirdServeOffense2==998
tab thirdServeOffense2
***Third serve offense 3***
tab V594, nol
gen thirdServeOffense3=V594
replace thirdServeOffense3=999 if thirdServeOffense3==998
tab thirdServeOffense3
***Third serve offense 4***
tab V595, nol
gen thirdServeOffense4=V595
replace thirdServeOffense4=999 if thirdServeOffense4==998
tab thirdServeOffense4
***Third serve offense 5***
tab V596, nol
gen thirdServeOffense5=V596
replace thirdServeOffense5=999 if thirdServeOffense5==998
tab thirdServeOffense5
***Third serve admission Month***
tab V599, nol
gen thirdAdmitMonth=99
replace thirdAdmitMonth=V599 if V599!=98
tab thirdAdmitMonth
***Third serve admission Year***
tab V600, nol
gen thirdAdmitYear=V600
replace thirdAdmitYear=99 if V600==98 
tab thirdAdmitYear
***Third serve Age***
tab V602
gen thirdAdmitAge=V602
replace thirdAdmitAge=99 if thirdAdmitAge==98 
tab thirdAdmitAge
***Third serve as adult***
tab V597, nol
gen thirdServeAdult=9
replace thirdServeAdult=1 if (V597==1|V597==2) 
replace thirdServeAdult=0 if V597==3 
tab thirdServeAdult


***Fourth serve offense 1***
tab V608, nol
gen fourthServeOffense1=V608
replace fourthServeOffense1=999 if fourthServeOffense1==998
tab fourthServeOffense1
***Fourth serve offense 2***
tab V609, nol
gen fourthServeOffense2=V609
replace fourthServeOffense2=999 if fourthServeOffense2==998
tab fourthServeOffense2
***Fourth serve offense 3***
tab V610, nol
gen fourthServeOffense3=V610
replace fourthServeOffense3=999 if fourthServeOffense3==998
tab fourthServeOffense3
***Fourth serve offense 4***
tab V611, nol
gen fourthServeOffense4=V611
replace fourthServeOffense4=999 if fourthServeOffense4==998
tab fourthServeOffense4
***Fourth serve offense 5***
tab V612, nol
gen fourthServeOffense5=V612
replace fourthServeOffense5=999 if fourthServeOffense5==998
tab fourthServeOffense5
***Fourth serve admission Month***
tab V615, nol
gen fourthAdmitMonth=99
replace fourthAdmitMonth=V615 if V615!=98
tab fourthAdmitMonth
***Fourth serve admission Year***
tab V616, nol
gen fourthAdmitYear=99
replace fourthAdmitYear=V616 if V616!=98
tab fourthAdmitYear
***Fourth serve Age***
tab V618
gen fourthAdmitAge=V618
replace fourthAdmitAge=99 if fourthAdmitAge==98 
tab fourthAdmitAge
***Fourth serve as adult***
tab V613, nol
gen fourthServeAdult=9
replace fourthServeAdult=1 if (V613==1 | V613==2) 
replace fourthServeAdult=0 if V613==3
tab fourthServeAdult


***Fifth serve offense 1***
tab V624, nol
gen fifthServeOffense1=V624
replace fifthServeOffense1=999 if fifthServeOffense1==998
tab fifthServeOffense1
***Fifth serve offense 2***
tab V625, nol
gen fifthServeOffense2=V625
replace fifthServeOffense2=999 if fifthServeOffense2==998
tab fifthServeOffense2
***Fifth serve offense 3***
tab V626, nol
gen fifthServeOffense3=V626
replace fifthServeOffense3=999 if fifthServeOffense3==998
tab fifthServeOffense3
***Fifth serve offense 4***
tab V627, nol
gen fifthServeOffense4=V627
replace fifthServeOffense4=999 if fifthServeOffense4==998
tab fifthServeOffense4
***Fifth serve offense 5***
tab V628, nol
gen fifthServeOffense5=V628
replace fifthServeOffense5=999 if fifthServeOffense5==998
tab fifthServeOffense5
***Fifth serve admission Month***
tab V631, nol
gen fifthAdmitMonth=99 
replace fifthAdmitMonth=V631 if V631!=98 
tab fifthAdmitMonth
***Fifth serve admission Year***
tab V632, nol
gen fifthAdmitYear=99
replace fifthAdmitYear=V632 if V632!=98 
tab fifthAdmitYear
***Fifth serve Age***
tab V634
gen fifthAdmitAge=V634
replace fifthAdmitAge=99 if fifthAdmitAge==98 
tab fifthAdmitAge
***Fifth serve as adult***
tab V629, nol
gen fifthServeAdult=9
replace fifthServeAdult=1 if (V629==1|V629==2) 
replace fifthServeAdult=0 if V629==3
tab fifthServeAdult



***Sixth serve offense 1***
tab V640, nol
gen sixthServeOffense1=V640
replace sixthServeOffense1=999 if sixthServeOffense1==998
tab sixthServeOffense1
***Sixth serve offense 2***
tab V641, nol
gen sixthServeOffense2=V641
replace sixthServeOffense2=999 if sixthServeOffense2==998
tab sixthServeOffense2
***Sixth serve offense 3***
tab V642, nol
gen sixthServeOffense3=V642
replace sixthServeOffense3=999 if sixthServeOffense3==998
tab sixthServeOffense3
***Sixth serve offense 4***
tab V643, nol
gen sixthServeOffense4=V643
replace sixthServeOffense4=999 if sixthServeOffense4==998
tab sixthServeOffense4
***Sixth serve offense 5***
tab V644, nol
gen sixthServeOffense5=V644
replace sixthServeOffense5=999 if sixthServeOffense5==998
tab sixthServeOffense5
***Sixth serve admission Month***
tab V647, nol
gen sixthAdmitMonth=99
replace sixthAdmitMonth=V647 if V647!=98
tab sixthAdmitMonth
***Sixth serve admission Year***
tab V648, nol
gen sixthAdmitYear=99
replace sixthAdmitYear=V648 if V648!=98  
tab sixthAdmitYear
***Sixth serve Age***
tab V650
gen sixthAdmitAge=V650
replace sixthAdmitAge=99 if sixthAdmitAge==98 
tab sixthAdmitAge
***Sixth serve as adult***
tab V645, nol
gen sixthServeAdult=9
replace sixthServeAdult=1 if (V645==1 | V645==2 ) 
replace sixthServeAdult=0 if V645==3 
tab sixthServeAdult



***Seventh serve offense 1***
tab V656, nol
gen seventhServeOffense1=V656
replace seventhServeOffense1=999 if seventhServeOffense1==998
tab seventhServeOffense1
***Seventh serve offense 2***
tab V657, nol
gen seventhServeOffense2=V657
replace seventhServeOffense2=999 if seventhServeOffense2==998
tab seventhServeOffense2
***Seventh serve offense 3***
tab V658, nol
gen seventhServeOffense3=V658
replace seventhServeOffense3=999 if seventhServeOffense3==998
tab seventhServeOffense3
***Seventh serve offense 4***
tab V659, nol
gen seventhServeOffense4=V659
replace seventhServeOffense4=999 if seventhServeOffense4==998
tab seventhServeOffense4
***Seventh serve offense 5***
tab V660, nol
gen seventhServeOffense5=V660
replace seventhServeOffense5=999 if seventhServeOffense5==998
tab seventhServeOffense5
***Seventh serve admission Month***
tab V663, nol
gen seventhAdmitMonth=99
replace seventhAdmitMonth=V663 if V663!=98
tab seventhAdmitMonth
***Seventh serve admission Year***
tab V664, nol
gen seventhAdmitYear=99
replace seventhAdmitYear=V664 if V664!=98 
tab seventhAdmitYear
***Seventh serve Age***
tab V666
gen seventhAdmitAge=V666
replace seventhAdmitAge=99 if seventhAdmitAge==98 
tab seventhAdmitAge
***Seventh serve as adult***
tab V661, nol
gen seventhServeAdult=9
replace seventhServeAdult=1 if (V661==1 | V661==2 )
replace seventhServeAdult=0 if V661==3
tab seventhServeAdult



***Eighth serve offense 1***
tab V672, nol
gen eighthServeOffense1=V672
replace eighthServeOffense1=999 if eighthServeOffense1==998
tab eighthServeOffense1
***Eighth serve offense 2***
tab V673, nol
gen eighthServeOffense2=V673
replace eighthServeOffense2=999 if eighthServeOffense2==998
tab eighthServeOffense2
***Eighth serve offense 3***
tab V674, nol
gen eighthServeOffense3=V674
replace eighthServeOffense3=999 if eighthServeOffense3==998
tab eighthServeOffense3
***Eighth serve offense 4***
tab V675, nol
gen eighthServeOffense4=V675
replace eighthServeOffense4=999 if eighthServeOffense4==998
tab eighthServeOffense4
***Eighth serve offense 5***
tab V676, nol
gen eighthServeOffense5=V676
replace eighthServeOffense5=999 if eighthServeOffense5==998
tab eighthServeOffense5
***Eighth serve admission Month***
tab V679, nol
gen eighthAdmitMonth=99
replace eighthAdmitMonth=V679 if V679!=98
tab eighthAdmitMonth
***Eighth serve admission Year***
tab V680, nol
gen eighthAdmitYear=99
replace eighthAdmitYear=V680 if V680!=98 
tab eighthAdmitYear
***Eighth serve Age***
tab V682
gen eighthAdmitAge=V682
replace eighthAdmitAge=99 if eighthAdmitAge==98 
tab eighthAdmitAge
***Eighth serve as adult***
tab V677, nol
gen eighthServeAdult=9
replace eighthServeAdult=1 if ( V677==2 | V677==1 ) 
replace eighthServeAdult=0 if V677==3 
tab eighthServeAdult



***Ninth serve offense 1***
tab V688, nol
gen ninthServeOffense1=V688
replace ninthServeOffense1=999 if ninthServeOffense1==998
tab ninthServeOffense1
***Ninth serve offense 2***
tab V689, nol
gen ninthServeOffense2=V689
replace ninthServeOffense2=999 if ninthServeOffense2==998
tab ninthServeOffense2
***Ninth serve offense 3***
tab V690, nol
gen ninthServeOffense3=V690
replace ninthServeOffense3=999 if ninthServeOffense3==998
tab ninthServeOffense3
***Ninth serve offense 4***
tab V691, nol
gen ninthServeOffense4=V691
replace ninthServeOffense4=999 if ninthServeOffense4==998
tab ninthServeOffense4
***Ninth serve offense 5***
tab V692, nol
gen ninthServeOffense5=V692
replace ninthServeOffense5=999 if ninthServeOffense5==998
tab ninthServeOffense5
***Ninth serve admission Month***
tab V695, nol
gen ninthAdmitMonth=99 
replace ninthAdmitMonth=V695 if V695!=98
tab ninthAdmitMonth
***Ninth serve admission Year***
tab V696, nol
gen ninthAdmitYear=99
replace ninthAdmitYear=V696 if V696!=98 
tab ninthAdmitYear
***Ninth serve Age***
tab V698, nol
gen ninthAdmitAge=V698
replace ninthAdmitAge=99 if ninthAdmitAge==98 
tab ninthAdmitAge
***Ninth serve as adult***
tab V693, nol
gen ninthServeAdult=9
replace ninthServeAdult=1 if ( V693==1 | V693==2 )
replace ninthServeAdult=0 if V693==3 
tab ninthServeAdult


***Tenth serve offense 1***
tab V704, nol
gen tenthServeOffense1=V704
replace tenthServeOffense1=999 if tenthServeOffense1==995
tab tenthServeOffense1
***Tenth serve offense 2***
tab V705, nol
gen tenthServeOffense2=V705
replace tenthServeOffense2=999 if tenthServeOffense2==995
tab tenthServeOffense2
***Tenth serve offense 3***
tab V706, nol
gen tenthServeOffense3=V706
replace tenthServeOffense3=999 if tenthServeOffense3==995
tab tenthServeOffense3
***Tenth serve offense 4***
tab V707, nol
gen tenthServeOffense4=V707
replace tenthServeOffense4=999 if tenthServeOffense4==995
tab tenthServeOffense4
***Tenth serve offense 5***
tab V708, nol
gen tenthServeOffense5=V708
replace tenthServeOffense5=999 if tenthServeOffense5==995
tab tenthServeOffense5
***Tenth serve admission Month***
tab V711, nol
gen tenthAdmitMonth=99
replace tenthAdmitMonth=V711 if V711!=98
tab tenthAdmitMonth
***Tenth serve admission Year***
tab V712, nol
gen tenthAdmitYear=99
replace tenthAdmitYear=V712 if V712!=98 
tab tenthAdmitYear
***Tenth serve Age***
tab V714, nol
gen tenthAdmitAge=V714
replace tenthAdmitAge=99 if tenthAdmitAge==98 
tab tenthAdmitAge
***Tenth serve as adult***
tab V709, nol
gen tenthServeAdult=9
replace tenthServeAdult=1 if (V709==1|V709==2) 
replace tenthServeAdult=0 if V709==3 
tab tenthServeAdult


*****Social Economic Status*****
****has GED or Highschool Equivalent****
tab V849, nol
gen hasGedEqui=9
replace hasGedEqui=1 if V849==1
replace hasGedEqui=0 if V849==2
tab hasGedEqui
 
***Highest Grade Attended (no missing data)*** 
tab V847, nol
gen topGradeAttended=V847 if V847!=98
tab topGradeAttended

***Highest Grade Completed***
tab V848, nol
gen topGradeCompleted=99
replace topGradeCompleted=topGradeAttended if V848==1
replace topGradeCompleted=topGradeAttended-1 if V848==2
replace topGradeCompleted=0 if V847==0
tab topGradeCompleted

***Completed high school***
gen completeHighSchool=9
replace completeHighSchool=1 if topGradeCompleted>=12 & topGradeCompleted!=99
replace completeHighSchool=0 if topGradeCompleted<12
tab completeHighSchool

/***Any Formal Training or Job Skills***
gen formalTraining=9
replace formalTraining=1 if V496==1 
replace formalTraining=0 if V496==2
tab formalTraining
*/ 

***Job before Offense***
tab V850, nol
gen jobAtOffense=9
replace jobAtOffense=1 if V850==1  
replace jobAtOffense=0 if  V850==2
tab jobAtOffense

***Full Time Job***
tab V851, nol
gen fullTimeJob=9
replace fullTimeJob=1 if V851==1 
replace fullTimeJob=0 if  (V850==2 | V851==2 )
tab fullTimeJob

***Looking for Job***
tab V853, nol
gen lookForJob=9
replace lookForJob=1 if V853==1 
replace lookForJob=0 if V853==2
tab lookForJob

***Major Reason not Looking for Jobs***
tab V869, nol
gen reasonNotLooking=99 
replace reasonNotLooking=V869 if V869!=98
tab reasonNotLooking

/***Year last worked at a job ***
When did you last work at a job or business for at least 2       
     consecutive weeks? Exclude work done while in jail or prison: [Year]      
*/
tab V871, nol
gen yearLastWorked=99
replace yearLastWorked=V871 if V871!=98 
tab yearLastWorked

***Never Worked for 2 consecutive weeks***
tab V872, nol 
gen neverWorked=9
replace neverWorked=1 if (V872==0|V872==1)
replace neverWorked=0 if yearLastWorked!=99
tab neverWorked

***Free at least for one year before admission*** 
tab V875, nol
tab V1282, nol
gen freeAYear=9
replace freeAYear=1 if V875==1
replace freeAYear=0 if (V875==2| V1282==2)
tab freeAYear

***Monthly Income Received (during free time)***
tab V886, nol
gen monthIncome=9999
replace monthIncome=0 if V886==0 
replace monthIncome=50 if V886==1 
replace monthIncome=150 if V886==2 
replace monthIncome=250 if V886==3 
replace monthIncome=350 if V886==4
replace monthIncome=450 if V886==5
replace monthIncome=550 if V886==6
replace monthIncome=700 if V886==7
replace monthIncome=900 if V886==8
replace monthIncome=1100 if V886==9 
replace monthIncome=1350 if V886==10 
replace monthIncome=1750 if V886==11
replace monthIncome=2250 if V886==12
replace monthIncome=3750 if V886==13
replace monthIncome=5000 if V886==14

tab monthIncome

***Annual Income (year before the arrest)***
tab V895, nol 
gen annualIncome=9999999
replace annualIncome=0 if V895==0 
replace annualIncome=500 if V895==1 
replace annualIncome=1500 if V895==2 
replace annualIncome=2500 if V895==3 
replace annualIncome=3500 if V895==4 
replace annualIncome=4500 if V895==5 
replace annualIncome=5500 if V895==6
replace annualIncome=6750 if V895==7
replace annualIncome=8750 if V895==8 
replace annualIncome=11000 if V895==9
replace annualIncome=13500 if V895==10
replace annualIncome=17500 if V895==11
replace annualIncome=22500 if V895==12
replace annualIncome=37500 if V895==13
replace annualIncome=50000 if V895==14
tab annualIncome

***When free, receiving wage (1991: a year ago)***
tab V887, nol
gen receiveWage=9
replace receiveWage=1 if V887==1
replace receiveWage=0 if V887==98  
tab receiveWage

***When free, receiving SSI, welfare, UI
tab V888 
tab V889
tab V890
gen receiveSsi=9
replace receiveSsi=1 if (V888==2 | V889==3 | V890==4)
replace receiveSsi=0 if (V888!=2 & V889!=3 & V890!=4) 
tab receiveSsi

***When free, receiving from family and friends***
tab V891, nol
gen receiveFAndF=9
replace receiveFAndF=1 if V891==5 
replace receiveFAndF=0 if V891!=5 
tab receiveFAndF
***When free, receiving illegal income***
tab V892, nol
gen receiveIllegalIncome=9
replace receiveIllegalIncome=1 if V892==6 
replace receiveIllegalIncome=0 if V892!=6 
tab receiveIllegalIncome
***When free, receiving education grant***
tab V893, nol
gen receiveEducGrant=9
replace receiveEducGrant=1 if V893==7
replace receiveEducGrant=0 if V893!=7 
tab receiveEducGrant
***When free, receiving anything else***
tab V894, nol
gen receiveAnythingElse=9
replace receiveAnythingElse=1 if V894==8
replace receiveAnythingElse=0 if V894!=8 
tab receiveAnythingElse
***Source of Income (Illegal: Most of it and some of it)***
tab V896, nol
gen illegalIncome=9
replace illegalIncome=1 if V896==1 | V896==2
replace illegalIncome=0 if V896==3 | V896==8
tab illegalIncome

***Support Someone Before Arrest***
tab V897, nol
gen supportOthersBeforeArrest=9
replace supportOthersBeforeArrest=1 if V897==1
replace supportOthersBeforeArrest=0 if V897==2
tab supportOthersBeforeArrest

***Number of Brothers and sisters***
tab V913, nol
gen numberSiblings=99
replace numberSiblings=V913 if V913!=98 
tab numberSiblings
 
***Who grow up with: Mother only*** 
tab V908, nol
gen growUpMotherOnly=9
replace growUpMotherOnly=1 if V908==1 
replace growUpMotherOnly=0 if V908!=1 & V908!=98 
tab growUpMotherOnly

***Who grow up with: Father only*** 
gen growUpFatherOnly=9
replace growUpFatherOnly=1 if V908==2 
replace growUpFatherOnly=0 if V908!=2 & V908!=98 
tab growUpFatherOnly

***Who grow up with: both parents*** 
gen growUpBothParents=9
replace growUpBothParents=1 if V908==3 
replace growUpBothParents=0 if V908!=3 & V908!=98 
tab growUpBothParents

***Who grow up with: Grandparents*** 
gen growUpGrandParents=9
replace growUpGrandParents=1 if V908==4
replace growUpGrandParents=0 if V908!=4 & V908!=98 
tab growUpGrandParents

***Who grow up with: Other relatives*** 
gen growUpOtherRelatives=9
replace growUpOtherRelatives=1 if V908==5
replace growUpOtherRelatives=0 if V908!=5 & V908!=98 
tab growUpOtherRelatives

***Who grow up with: Friends*** 
gen growUpFriends=9
replace growUpFriends=1 if V908==6
replace growUpFriends=0 if V908!=6 & V908!=98 
tab growUpFriends

***Who grow up with: Foster homes and institutions*** 
gen growUpFosterInst=99
replace growUpFosterInst=1 if V908==7 | V908==8
replace growUpFosterInst=0 if V908!=7 & V908!=8 & V908!=98
tab growUpFosterInst

***Who grow up with: Somewhere else*** 
gen growUpElse=99
replace growUpElse=1 if V908==9
replace growUpElse=0 if V908!=9 & V908!=98 
tab growUpElse

/***Oldest Child***
tab V571 
gen oldestChild=9
replace oldestChild=1 if V571==1
replace oldestChild=0 if V571==2

***Highest Grade Mother Attended***
tab V578, nol
gen higestGradeMother=99
replace higestGradeMother=V578 if V578!=97 & V578!=98 & V578!=99
tab higestGradeMother

***Highest Grade Father Attended***
tab V582, nol 
gen higestGradeFather=99
replace higestGradeFather=V582 if V582!=97 & V582!=98 & V582!=99
tab higestGradeFather
*/ 
***Gorw up with parents drug and alcohol abusing*** 
tab V911, nol
gen growUpParentsDrugAlcohol=9
replace growUpParentsDrugAlcohol=1 if V911==1
replace growUpParentsDrugAlcohol=0 if V911==2 
tab growUpParentsDrugAlcohol

***Anyone in family ever served in jail or prison***
tab V914, nol
gen familyServed=9
replace familyServed=1 if V914==1 
replace familyServed=0 if V914==2
tab familyServed

***Mother served before***
tab V916, nol
gen motherServed=9
replace motherServed=1 if V916==2 
replace motherServed=0 if (V916==8 | V914==2) & familyServed!=9
tab motherServed

***Father served before***
tab V917, nol
gen fatherServed=9
replace fatherServed=1 if V917==3
replace fatherServed=0 if (V917==8 | V914==2) & familyServed!=9
tab fatherServed

***Be abused physically before 18***
tab V979, nol
gen abusedPhyBefore=9 
replace abusedPhyBefore=1 if (V979==3 & (V980==4 | V980==6)) & V982==1
replace abusedPhyBefore=0 if  (V979==1 | V980==5 | V982==2 )
tab abusedPhyBefore

***Be abused sexually before 18***
gen abusedSexBefore=9 
replace abusedSexBefore=1 if (V979==3 & (V980==5 | V980==6)) & V982==1
replace abusedSexBefore=0 if  (V979==1 | V980==4 | V982==2 )
tab abusedSexBefore

***Be abused both sexually and physically before 18***
gen abusedSexnPhyBefore=9 
replace abusedSexnPhyBefore=1 if V980==6 & V982==1
replace abusedSexnPhyBefore=0 if (V980!=6 & V980!=8) | V979==1 | V982==2
tab abusedSexnPhyBefore

***Have Children***
tab V921, nol
gen haveChildren=9 
replace haveChildren=1 if V921==1
replace haveChildren=0 if V921==2
tab haveChildren

***Friends who engage in illegal activities***
gen friendsDoIllegal=9
replace friendsDoIllegal=1 if (V952==1|V953==2|V954==3|V955==4|V956==5|V957==6|V958==7| ///
V959==8|V960==9|V961==10)
replace friendsDoIllegal=0 if V962==0 
tab friendsDoIllegal

***Ever use any drugs***
tab V1000, nol 
tab V1007, nol 
tab V1014, nol
tab V1021, nol
tab V1028, nol 
tab V1035, nol 
tab V1042, nol 
tab V1049, nol 
tab V1056, nol 
tab V1063, nol
tab V1070, nol
tab V1077, nol 

gen everUseDrug=9 
replace everUseDrug=1 if V1000==1 
replace everUseDrug=1 if V1007==1 
replace everUseDrug=1 if V1014==1
replace everUseDrug=1 if V1021==1
replace everUseDrug=1 if V1028==1
replace everUseDrug=1 if V1035==1 
replace everUseDrug=1 if V1042==1 
replace everUseDrug=1 if V1049==1 
replace everUseDrug=1 if V1056==1 
replace everUseDrug=1 if V1063==1 
replace everUseDrug=1 if V1070==1 
replace everUseDrug=1 if V1077==1 

replace everUseDrug=0 if (V1000==2 & V1007==2 & V1014==2 & V1021==2 & V1028==2 /// 
& V1035==2 & V1042==2 & V1049==2 & V1056==2 & V1063==2 & V1070==2 & V1077==2)

tab everUseDrug

***Age First Use Drugs***
tab V1001, nol 
tab V1008, nol 
tab V1015, nol 
tab V1022, nol
tab V1029, nol 
tab V1036, nol 
tab V1043, nol 
tab V1050, nol 
tab V1057, nol 
tab V1064, nol
tab V1071, nol 
tab V1078, nol

gen ageFirstUseAnyDrugs=99
replace ageFirstUseAnyDrugs=min(V1001, V1008, V1015, V1022, V1029, V1036, V1043, /// 
V1050, V1057, V1064, V1071, V1078) 
replace ageFirstUseAnyDrugs=99 if (ageFirstUseAnyDrugs==98) 
tab ageFirstUseAnyDrugs 

***Ever use any drugs on a regular basis***
tab V1003, nol 
tab V1010, nol 
tab V1017, nol
tab V1024, nol
tab V1031, nol 
tab V1038, nol 
tab V1045, nol 
tab V1052, nol 
tab V1059, nol 
tab V1066, nol
tab V1073, nol 
tab V1080, nol

gen useDrugReg=9 
replace useDrugReg=1 if V1003==1 
replace useDrugReg=1 if V1010==1 
replace useDrugReg=1 if V1017==1
replace useDrugReg=1 if V1024==1
replace useDrugReg=1 if V1031==1 
replace useDrugReg=1 if V1038==1 
replace useDrugReg=1 if V1045==1 
replace useDrugReg=1 if V1052==1 
replace useDrugReg=1 if V1059==1 
replace useDrugReg=1 if V1066==1 
replace useDrugReg=1 if V1073==1 
replace useDrugReg=1 if V1080==1 

replace useDrugReg=0 if everUseDrug==0 

replace useDrugReg=0 if ((V1000==2 | V1003==2) & (V1007==2 | V1010==2) & ///
 (V1014==2 | V1017==2) & (V1021==2 | V1024==2) & (V1028==2 | V1031==2) & /// 
 (V1035==2 | V1038==2) & (V1042==2 | V1045==2) & (V1049==2 | V1052==2) & /// 
 (V1056==2 | V1059==2) & (V1063==2 | V1066==2) & (V1070==2 | V1073==2) & ///
 (V1077==2 | V1080==2))   
 
tab useDrugReg
tab everUseDrug

/***Age First Use Drugs on a regular basis***
tab V905, nol 
tab V916, nol 
tab V925, nol 
tab V934, nol
tab V943, nol 
tab V952, nol 
tab V961, nol 
tab V970, nol 
tab V979, nol
tab V988, nol 

drop ageFirstUseDrugsRegular
gen ageFirstUseDrugsRegular=99
replace ageFirstUseDrugsRegular=min(V905, V916, V925, V934, V943, V952, V961, /// 
V970, V979, V988) 
replace ageFirstUseDrugsRegular=99 if (ageFirstUseDrugsRegular==97 | ageFirstUseDrugsRegular==98) 
tab ageFirstUseDrugsRegular
*/ 
***Whether using drugs before the current offense (1986: current admission)***
tab V1004, nol
tab V1011, nol
tab V1018, nol
tab V1025, nol
tab V1032, nol 
tab V1039, nol 
tab V1046, nol 
tab V1053, nol 
tab V1060, nol
tab V1067, nol
tab V1074, nol
tab V1081, nol

tab V1000, nol 
tab V1007, nol 
tab V1014, nol
tab V1021, nol
tab V1028, nol 
tab V1035, nol 
tab V1042, nol 
tab V1049, nol 
tab V1056, nol 
tab V1063, nol
tab V1070, nol
tab V1077, nol 

gen useDrugBeforeCurrentOffense=9 
replace useDrugBeforeCurrentOffense=1 if (V1004==1 | V1011==1 | V1018==1 | V1025==1 | /// 
V1032==1 | V1039==1 | V1046==1 | V1053==1 | V1060==1 | V1067==1 | V1074==1 | V1081==1)

replace useDrugBeforeCurrentOffense=0 if ((V1000==2)| V1004==2) & /// 
((V1007==2)| V1011==2) & ((V1014==2)| V1018==2) &  /// 
((V1021==2)| V1025==2) & ((V1028==2)| V1032==2) &  ///
((V1035==2)| V1039==2) & ((V1042==2)| V1046==2) &  ///
((V1049==2)| V1053==2) & ((V1056==2)| V1060==2) &  ///
((V1063==2)| V1067==2) & ((V1070==2)| V1074==2) &  ///
((V1077==2)| V1081==2)

tab useDrugBeforeCurrentOffense

/***Whether using drugs before the first offense***
tab V625, nol
tab V641, nol
tab V657, nol
tab V673, nol 
tab V689, nol 
tab V705, nol 
tab V721, nol 
tab V737, nol
tab V753, nol

drop useDrugBeforeFirstOffense
gen useDrugBeforeFirstOffense=9 
replace useDrugBeforeFirstOffense=1 if (V625==1 | V641==1 | V657==1 | V673==1 | /// 
V689==1 | V705==1 | V721==1 | V737==1 | V753==1)
replace useDrugBeforeFirstOffense=0 if ((V625==2 & V641==2 & V657==2 & V673==2 & /// 
V689==2 & V705==2 & V721==2 & V737==2 & V753==2) | (V625==9 & V641==9 & V657==9 & V673==9 & /// 
V689==9 & V705==9 & V721==9 & V737==9 & V753==9) )
tab useDrugBeforeFirstOffense
*/ 
/***Whether participated in any drug treatment program 
tab V1010, nol 
gen useDrugProgram=9
replace useDrugProgram=1 if V1010==1 
replace useDrugProgram=0 if V1010==2
tab useDrugProgram
*/ 

***Under the influence of drug for the current offense 
tab V1097, nol 
tab everUseDrug
tab useDrugReg
gen underDrugInfluence=9
replace underDrugInfluence=1 if V1097==1 
replace underDrugInfluence=0 if (V1097==2 |useDrugBeforeCurrentOffense==0  )
tab underDrugInfluence

save sisfcf_1991, replace 




























